package com.example.qxapp.activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.example.qxapp.Fragment.Collectfragmentcom;
import com.example.qxapp.Fragment.Collectfragmentpush;
import com.example.qxapp.R;
import com.het.smarttab.SmartTabLayout;
import com.het.smarttab.v4.FragmentPagerItem;
import com.het.smarttab.v4.FragmentPagerItems;
import com.het.smarttab.v4.FragmentStatePagerItemAdapter;


import java.util.List;

public class MycollectActivity extends AppCompatActivity {
    private SmartTabLayout smartTabLayout;
    private ViewPager viewPager;

    private ImageView back;

    private FragmentStatePagerItemAdapter fragadapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mycollect);
        init();
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        viewPager.setCurrentItem(3);
        inittab();
    }

    private void inittab() {
        String[] tabs = new String[]{"帖子","论坛"};
        FragmentPagerItems pagerItems=new FragmentPagerItems(MycollectActivity.this);
        for (int i=0;i<tabs.length;i++){
            Bundle bundle=new Bundle();
            bundle.putString("name",tabs[i]);
        }
        pagerItems.add(FragmentPagerItem.of(tabs[0], Collectfragmentpush.class));
        pagerItems.add(FragmentPagerItem.of(tabs[1], Collectfragmentcom.class));

        viewPager.removeAllViews();
        fragadapter=new FragmentStatePagerItemAdapter(getSupportFragmentManager(),pagerItems);
        viewPager.setAdapter(fragadapter);
        smartTabLayout.setViewPager(viewPager);
    }

    private void init() {
        smartTabLayout = findViewById(R.id.mycollecttab);
        viewPager = findViewById(R.id.mycollectvp);
        back = findViewById(R.id.back);
    }
}
